package enumdemo;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class Constant {
    public static final int RED = 1;
    public static final int WHITE = 2;
    public static final int GREEN = 3;


//不能通过反射创建枚举
    public static void main(String[] args) throws ClassNotFoundException{
        Class<?> c = Class.forName("enumdemo.TestEnum");
        try{
            Constructor<?> constructor =
                    c.getDeclaredConstructor(String.class,int.class,int.class,String.class);
            constructor.setAccessible(true);
            TestEnum testEnum = (TestEnum) constructor.newInstance("hello",99,99,"ceshi");
        }catch(NoSuchMethodException e){
            throw new RuntimeException(e);
        } catch (InvocationTargetException e) {
            throw new RuntimeException(e);
        } catch (InstantiationException e) {
            throw new RuntimeException(e);
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        }
    }

}
